package com.ruoyi.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basic.domain.AtbQueryNavigation;
import com.ruoyi.common.core.domain.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basic.domain.AtbShap;
import com.ruoyi.basic.service.IAtbShapService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地产商业基本信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-14
 */
@RestController
@RequestMapping("/basic/basic")
public class AtbShapController extends BaseController
{
    @Autowired
    private IAtbShapService atbShapService;

    /**
     * 查询地产商业基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('basic:basic:list')")
    @GetMapping("/list")
    public TableDataInfo list(AtbShap atbShap)
    {
        startPage();
        List<AtbShap> list = atbShapService.selectAtbShapList(atbShap);
        return getDataTable(list);
    }

    /**
     * 导出地产商业基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('basic:basic:export')")
    @Log(title = "地产商业基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AtbShap atbShap)
    {
        List<AtbShap> list = atbShapService.selectAtbShapList(atbShap);
        ExcelUtil<AtbShap> util = new ExcelUtil<AtbShap>(AtbShap.class);
        util.exportExcel(response, list, "地产商业基本信息数据");
    }

    /**
     * 获取地产商业基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:basic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(atbShapService.selectAtbShapById(id));
    }

    /**
     * 新增地产商业基本信息
     */
    @PreAuthorize("@ss.hasPermi('basic:basic:add')")
    @Log(title = "地产商业基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AtbShap atbShap)
    {
        return toAjax(atbShapService.insertAtbShap(atbShap));
    }

    /**
     * 修改地产商业基本信息
     */
    @PreAuthorize("@ss.hasPermi('basic:basic:edit')")
    @Log(title = "地产商业基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AtbShap atbShap)
    {
        return toAjax(atbShapService.updateAtbShap(atbShap));
    }

    /**
     * 删除地产商业基本信息
     */
    @PreAuthorize("@ss.hasPermi('basic:basic:remove')")
    @Log(title = "地产商业基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(atbShapService.deleteAtbShapByIds(ids));
    }


    //导航列表集合
    @PreAuthorize("@ss.hasPermi('basic:basic:atbQueryNavigationList')")
    @GetMapping("/atbQueryNavigationList")
    public AjaxResult atbQueryNavigationList()
    {

        List<AtbQueryNavigation> list = atbShapService.atbQueryNavigationList();
        System.out.println(list);
        return AjaxResult.success(list);
    }




    @PreAuthorize("@ss.hasPermi('basic:basic:getSelectTypeIdById')")
    @GetMapping(value = "/getSelectTypeIdById/{id}")
    public R getSelectTypeIdById(@PathVariable("id") Long id)
    {
        return R.ok(atbShapService.getSelectTypeIdById(id));
    }







}
